package cc.opcol.iot.app.task;

import cc.opcol.iot.app.auth.UserSessionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class DeadUserSessionTask {

    private final static Logger logger = LoggerFactory.getLogger(DeadUserSessionTask.class);

    @Autowired
    UserSessionService userSessionService;

    @Scheduled(fixedRate = 1000*60)
    public void hand(){
        try{
            //logger.debug("Release expired user session");
            userSessionService.releaseDeadSession();
        }catch (Exception e){
            logger.error("",e);
        }
    }
}
